Skip to content

feat: add lazy CLI extensions - #863

Merged
nabinchha merged 3 commits into
feat/slurm-executionfrom
andreatnvidia/feat/lazy-cli-extensions
Aug 18, 2026
Merged

feat: add lazy CLI extensions#863
nabinchha merged 3 commits into
feat/slurm-executionfrom
andreatnvidia/feat/lazy-cli-extensions

Conversation

@andreatnvidia

@andreatnvidia andreatnvidia commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a minimal entry-point seam for optional packages to provide top-level data-designer command groups without importing their implementation until selected.

Related issues

Closes #853

Depends on #856
Related to #850

Changes

  • Discover optional groups from data_designer.cli entry-point metadata.
  • Keep root help metadata-only and load only the selected extension factory.
  • Validate Data Designer version compatibility and the returned Click command only after command selection.
  • Reject built-in collisions and duplicate names deterministically without loading either target.
  • Ignore malformed registrations with targeted warnings so they do not disable built-in commands.
  • Register the optional Slurm package as the first extension.
  • Extend installed-wheel smoke tests with base-only, extra-installed, lazy-import, and absolute/relative startup-budget checks.
  • Document the entry-point and callable contract.

Impact

A base-only install has no slurm command. Installing data-designer[slurm] adds data-designer slurm, while root help and unrelated commands do not import data_designer.slurm or compatibility-checking modules.

F2 intentionally establishes the extension seam and an empty Slurm group. Leaf subcommands are owned by follow-up API work. A generic nested-command test proves the seam supports deeper command trees and preserves leaf exit codes.

This PR is stacked on #856 and should be retargeted to main after F1 merges.

Testing

  • .venv/bin/pytest packages/data-designer/tests packages/data-designer-slurm/tests -p no:cacheprovider (1146 passed, 1 skipped)
  • make test-slurm-wheel-install (0.574 s base median, 0.568 s extension median; 1 s base and 100 ms overhead budgets)
  • .venv/bin/ruff check --fix .
  • .venv/bin/ruff format .
  • Pre-commit hooks on changed files

@andreatnvidia
andreatnvidia marked this pull request as ready for review August 13, 2026 16:42
@andreatnvidia
andreatnvidia requested a review from a team as a code owner August 13, 2026 16:42
@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds metadata-only discovery and lazy loading for optional top-level CLI extensions.

  • Registers the Slurm package as the first data_designer.cli entry point.
  • Validates extension compatibility and command factories when an extension is selected.
  • Handles built-in collisions, duplicate registrations, and malformed extension names.
  • Adds unit and installed-wheel coverage for dispatch, lazy imports, and startup budgets.
  • Documents the extension contract and lazy-loading behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/data-designer/src/data_designer/cli/lazy_group.py Adds metadata-only entry-point discovery, deferred extension loading, compatibility validation, and deterministic collision handling; no eligible follow-up finding was established.
packages/data-designer/src/data_designer/cli/main.py Enables optional extension discovery on the root CLI group.
packages/data-designer-slurm/src/data_designer/slurm/cli.py Adds the initial empty Slurm command group and its Click-command factory.
packages/data-designer-slurm/pyproject.toml Registers the Slurm command factory in the new CLI entry-point group.
packages/data-designer/tests/cli/test_lazy_group.py Covers lazy discovery, dispatch, compatibility checks, collisions, malformed registrations, and nested-command behavior.
scripts/test_slurm_package_install.py Extends wheel smoke testing with extension visibility, lazy-import assertions, and root-help startup budgets.

Sequence Diagram

sequenceDiagram
    participant User
    participant Root as data-designer root
    participant Metadata as Entry-point metadata
    participant Factory as Extension factory
    participant Command as Extension command
    User->>Root: --help
    Root->>Metadata: Discover names and summaries
    Metadata-->>Root: Extension metadata
    Root-->>User: Help without importing extension
    User->>Root: slurm ...
    Root->>Metadata: Resolve selected entry point
    Root->>Root: Validate version compatibility
    Root->>Factory: Load and invoke factory
    Factory-->>Root: click.Command
    Root->>Command: Dispatch arguments
    Command-->>User: Result
Loading

Reviews (3): Last reviewed commit: "refactor: order public CLI members first" | Re-trigger Greptile

@andreatnvidia
andreatnvidia changed the base branch from andreatnvidia/feat/slurm-package to feat/slurm-execution August 17, 2026 14:27
Signed-off-by: Andre Manoel <amanoel@nvidia.com>
Signed-off-by: Andre Manoel <amanoel@nvidia.com>
@nabinchha
nabinchha force-pushed the andreatnvidia/feat/lazy-cli-extensions branch from d549d81 to d657a4c Compare August 18, 2026 16:00
Signed-off-by: Nabin Mulepati <nmulepati@nvidia.com>

@nabinchha nabinchha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together, @andreatnvidia!

Summary

This adds metadata-only discovery for optional top-level CLI groups, validates and loads only the selected extension, and registers the optional Slurm package as the first consumer. The implementation matches the PR's stated lazy-loading and failure-isolation goals.

Findings

Suggestions — Take it or leave it

packages/data-designer-slurm/src/data_designer/slurm/cli.py:9 — Keep completion controls at the root

  • What: The Slurm typer.Typer uses the default add_completion=True, so data-designer slurm --help exposes --install-completion and --show-completion. The root app explicitly disables these options, and built-in subgroups do not expose them.
  • Why: This makes the first extension group behave differently from the rest of the CLI and lets a nested group re-enable shell-completion controls that the root intentionally omits.
  • Suggestion: Set add_completion=False on the Slurm app and add a small help-output assertion to keep the embedded group aligned with the root CLI.

What Looks Good

  • Root help remains metadata-only; the wheel smoke test verifies that neither the Slurm module nor compatibility-checking modules are imported.
  • Compatibility failures, malformed registrations, duplicate names, and built-in collisions are isolated with targeted errors and strong behavioral coverage.
  • The generic nested-command test verifies real dispatch behavior and preserves leaf exit codes rather than only checking mocks.

Verdict

Ship it (with nits) — the completion-option inconsistency is optional and does not block merge.


This review was generated by an AI assistant.

@nabinchha
nabinchha merged commit d20d0a4 into feat/slurm-execution Aug 18, 2026
7 checks passed
@nabinchha
nabinchha deleted the andreatnvidia/feat/lazy-cli-extensions branch August 18, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants